package 工厂方法模式.结合策略模式.商场促销再升级;

import 装饰模式.商场促销实例.CashNormal;
import 装饰模式.商场促销实例.CashRebate;
import 装饰模式.商场促销实例.CashReturn;
import 装饰模式.商场促销实例.ISale;

/**
 * @author zyl
 * @Description
 * @since 2024/1/3 14:45
 */

public class CashContext {
    private ISale iSale;
    public CashContext(int cashType) {
        IFactory iFactory = null;

        switch (cashType){
            case 1:
                iFactory = new CashRebateReturn(1,0,0);
                break;
            case 2:
                iFactory = new CashRebateReturn(0.8D,0,0);
                break;
            case 3:
                iFactory = new CashRebateReturn(0.7d,0,0);
                break;
            case 4:
                iFactory = new CashReturnRebate(300d,100d,1);
                break;
            case 5:
                //先打折再返利
                iFactory = new CashRebateReturn(0.7d,300d,100d);
                break;
            case 6:
                //先返利再打折
                iFactory = new CashReturnRebate(0.7d,300d,100d);
                break;
        }
        this.iSale = iFactory.createSalesModel();
    }

    public double getPriceResults(double price, int num){
        return this.iSale.acceptCash(price, num);
    }
}
